 $(function () {
        $('.name img').click(function () {
            $('.name input[type=file]').click();
        })
        $('.address').click(function () {
            window.location.href='../distence/distence.html';
        })
        var token=localStorage.phone;
        $.ajax({
            url:"https://newapp.icandrive.cn/api/set.php",
            type:'post',
            dataType:'json',
            data:{token:token},
            success: function (data) {

                if(data.status==200){
                    $(data.dataing).each(function () {
                        $('.portrait').attr('src',this.teacher_photo);
                        $('.name').val(this.teacher_name);
                        $('.id_number').val(this.ID_number);
                         $('.zfb').val(this.alipay_account);
                    })
                }
            },
            error: function () {
            }
        })
    });
    var xhr;

    function createXMLHttpRequest() {
        if (window.ActiveXObject) {
            xhr = new ActiveXObject("Microsoft.XMLHTTP");
        } else if (window.XMLHttpRequest) {
            xhr = new XMLHttpRequest();
        }
    }

    function UpladFile() {
        var f=document.getElementById("file").value;
        if(!/\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/.test(f))
        {
            layer.msg("请选择正确格式的图片");
            return false;
        }
        var token=localStorage.phone;
        var fileObj = document.getElementById("file").files[0];
        var FileController = 'https://newapp.icandrive.cn/api/photo.php?token='+token;
        var form = new FormData();
        form.append("myfile", fileObj);
        createXMLHttpRequest();
        xhr.onreadystatechange = handleStateChange;
        xhr.open("post", FileController, true);
        xhr.send(form);
    }
    function handleStateChange() {
        if (xhr.readyState == 4) {
            if (xhr.status == 200 || xhr.status == 0) {
                var result = xhr.responseText;
                var json = eval("(" + result + ")");
                setTimeout(function(){
                    history.go(0)
                },2000)

            }
        }
    }
